//
//  ViewController.m
//  UI08_页面间传值
//
//  Created by Scott on 16/5/12.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"
#import "ModelOfPic.h"

@interface ViewController ()

@property (nonatomic, retain) UITextField *tfOfUser;

@end

@implementation ViewController

- (void)dealloc {
    [_tfOfUser release];
    [super dealloc];
}

- (void)viewDidLoad {
    ModelOfPic *model = [ModelOfPic sharedModelOfPic];
    
    
    [super viewDidLoad];
    
    [self createTextField];

    self.navigationItem.title = @"第一页";
    
    UIBarButtonItem *itemOfleft = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(handleNext)];
    
    self.navigationItem.rightBarButtonItem = itemOfleft;
    
    [itemOfleft release];
    
}

- (void)createTextField {
    
    self.tfOfUser = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 300, 40)];
    [self.view addSubview:self.tfOfUser];
    [_tfOfUser release];
    
    self.tfOfUser.borderStyle = 3;
    self.tfOfUser.backgroundColor = [UIColor cyanColor];
    
}

#pragma mark - 知识点1: 属性传值.
- (void)handleNext {

    VCOfSecond *second = [[VCOfSecond alloc] init];
    NSLog(@"%s", __FUNCTION__);
    
    
    // 属性赋值.
    second.contentOfLabel = self.tfOfUser.text;
    
//    second.view.backgroundColor = [UIColor orangeColor];
    
    second.navigationItem.title = self.tfOfUser.text;
    
    
    NSLog(@"%s", __FUNCTION__);
    
    
    [self.navigationController pushViewController:second animated:YES];
    NSLog(@"%s", __FUNCTION__);
    
    [second release];
    
}







@end
